home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10105 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.9 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: C uses simple LALR parsing?
  5. Date: 15 Mar 1996 17:10:54 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Mar15101054@qcd.lanl.gov>
  8. References: <4i9ilq$92a@sargas.omicron.se>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: elias@omicron.se's message of 14 Mar 1996 16:48:58 GMT
  13.  
  14. In article <4i9ilq$92a@sargas.omicron.se>
  15. elias@omicron.se (Elias Martenson) writes:
  16.  
  17. EM: This question has been subject to major debate among me and my firends:
  18. EM: 
  19. EM: Does the C standard specify what kind of parser to use? If it uses
  20.  
  21. It is useful in C to distinguish the stages of lexing and parsing.
  22. A pp-token is the longest sequence at that point which could be a pp-token.
  23.  
  24. EM: (and is does seem that at least AT&T C and GCC does) a simple
  25. EM: LALR parser it would mean that the following expression:
  26. EM: 
  27. EM:     a+++++b
  28. EM: 
  29. EM: Yields:
  30. EM: 
  31. EM:     SYMBOL INCR INCR ADD SYMBOL
  32. EM: 
  33. EM: Instead of the desired result (which is acieved when doing a++ + ++b):
  34.  
  35. desired? I certainly don't desire that :-)
  36.  
  37. EM: 
  38. EM:     SYMBOL INCR ADD INCR SYNBOL
  39. EM: 
  40. EM: Is it legal for a C compiler to parse the expression like the last
  41. EM: example?
  42.  
  43. No.
  44.  
  45. The only place where the lexing of C seems to surprise people is in
  46. `0x1e+1' kind of stuff being invalid. That is because pp-numbers are
  47. much larger category of objects than numbers. 
  48.  
  49. Tanmoy
  50. --
  51. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  52. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  53. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  54. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  55. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  56. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  57.